<?php
// File Security Check
if ( ! empty( $_SERVER['SCRIPT_FILENAME'] ) && basename( __FILE__ ) == basename( $_SERVER['SCRIPT_FILENAME'] ) ) :
	die ( 'You do not have sufficient permissions to access this page!' );
endif;

/* Template Name: Staff */

get_header(); ?>

<?php get_template_part( 'page-title' ); ?>

<!-- BEGIN #container -->
<div id="container" class="clearfix">

    <?php if ( have_posts() ) : ?>

        <?php while ( have_posts() ) : the_post(); ?>

            <!-- BEGIN #content -->
            <section id="content" class="col-full clearfix staff <?php echo $post->post_name; ?>">

                <div class="entry">
                        <?php the_content( __( 'Continue reading', 'nicethemes' ) . ' &raquo;' ); ?>
                </div>

                <?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
			$temp_query = $wp_query;

			$args = array(	'post_type'			=> 'staff',
							'posts_per_page'	=> -1,
							'no_found_rows'		=> true,
							'paged'				=> $paged,
							'orderby'			=> 'menu_order',
							'order'				=> 'ASC'
						);

			query_posts( $args );

			if ( have_posts() ) :

                            $loop = 0;
                            $columns = 3; ?>
                    
                            <ul id="staff-list">

				<?php while ( have_posts() ) :
                                        the_post();
                                        $loop++;

                                ?>
                                    <li data-id="id-<?php echo $loop; ?>" >
                                        
                                        <?php if ( has_post_thumbnail() ) : ?>
                                            <div class="post-image">
                                                <a href="<?php the_permalink(); ?>" title="<?php printf( __( 'Permanent Link to %s', 'nicethemes' ), get_the_title()); ?>">
                                                    <?php nice_image( array( 'key'	=> 'staff-image', 'width'  => 270, 'height' => 270 ) ) ; ?>
                                                </a>
                                            </div>
                                        <?php endif; ?>
                                        
                                        <div class="post-content">
                                            <div class="entry-title"><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php printf( __( 'Permanent Link to %s', 'nicethemes' ), get_the_title()); ?>"> <?php the_title(); ?></a></div>
                                            <div class="staff-deparment">
                                                <?php echo get_the_term_list( get_the_ID(), 'department', '', ', ', ''); ?>
                                            </div>
                                            <div class="staff-excerpt">
                                                <div class="excerpt-content">
                                                    <?php   
                                                        $bio = get_post_meta( get_the_ID(), 'bio', true );
                                                        $shortbio = wp_trim_words( $bio, $num_words = 50, $more = '... ' );
                                                        echo $shortbio; 
                                                    ?>
                                                </div>
                                            </div>
                                            <a class="readmore" href="<?php echo get_permalink( get_the_ID() ); ?>" title="<?php printf( __( 'Permanent Link to %s', 'nicethemes' ), get_the_title() ); ?>"> <?php _e( 'Read More', 'nicethemes' ); ?></a>
                                        </div>
		
                                    </li>

				<?php endwhile;?>

                            </ul>

			<?php endif; ?>
                
			<?php wp_reset_query(); ?>
			<?php $wp_query = clone $temp_query; ?>

             </section>
            <!-- END #content -->   
                
        <?php endwhile; ?>

    <?php else : ?>
            
        <header>
                <h2><?php _e( 'Not Found', 'nicethemes' ); ?></h2>
        </header>
        <p><?php _e( 'Sorry, but you are looking for something that isn\'t here.', 'nicethemes' ); ?></p>
        <?php get_search_form(); ?>

    <?php endif; ?>

<!-- END #container -->
</div>

<?php get_footer(); ?>